var payObj = {
    init: function() {
        this.getGoodsDetail();
        this.hidePtTip();
        this.pay();
    },
    getGoodsDetail: function() {
        var me = this;
        var url = magic_config.urlPrefix + 'GroupbuyService/getallgroupbuyinfo';
        if (me.userid == null) {
            sUserIdStr = "";
        } else {
            sUserIdStr = me.userid;
        }
        var data = {
            lTeamId: me.lTeamId,
            sUserId: sUserIdStr
        }
        $.ajax({
            url: url,
            type: 'get',
            data: data,
            async: false,
            dataType: 'json',
            success: function(res) {
                var nCode = res.return.nCode;
                if (nCode === 0) {
                    me.splitDetail(res.response.cdoData);
                } else {
                    console.log("数据请求失败，后到前");
                }
            },
            error: function(res) {
                console.log("数据请求失败，前到后");
            }
        });
    },
    splitDetail: function(goodsDetail) {
        //商品名字
        $(".goodsname").html(goodsDetail.sName);
        //商品价格
        $(".goodsprc").html('<span>拼团价&nbsp&nbsp&nbsp&nbsp¥&nbsp</span>' + goodsDetail.nGroupPrice);
        $(".paytip").html('应付款：<b>￥</b><span>' + goodsDetail.nGroupPrice + '</span>');
        $(".goodsoprc").html("¥" + goodsDetail.nMainPrice);
        $(".groupnum").html('<span>' + goodsDetail.nCountPerGroup + '</span>人参与');
        //商品图片
        $(".goodsimg").html('<img src="' + goodsDetail.sHeadPicture + '" alt="" />');
    },
    //关闭提示弹层
    hidePtTip: function() {
        var me = this;
        $(".pttipbtn").bind("click", function() {
            $(".layerbox").hide();
            $(".pt_tip_box").hide();
            $.cookie("tipfalge", "true", {　　
                path: "/",
                expires: 365
            })
            console.log("调用支付接口");
        })
    },
    //点击确认下单
    pay: function() {
        var me = this;
        $(".paybtn").bind("click", function() {
            if ($.cookie('tipfalge') == null) {
                $(".layerbox").show();
                $(".pt_tip_box").show();
            } else {
                console.log("调用支付接口");
            }
        })
    }
};
payObj.init();